package com.neusoft.hifly.gateway.utils;

/**
 * token的枚举信息
 */
public enum TokenState {

	/** 过期 */
	EXPIRED("EXPIRED"),

	/** 无效(token不合法) */
	INVALID("INVALID"),

	/** 有效的 */
	VALID("VALID");

	private String state;

	TokenState(final String state) {
		this.state = state;
	}

	/**
	 * 根据状态字符串获取token状态枚举对象
	 *
	 * @param tokenState
	 *            枚举信息
	 * @return TokenState信息
	 */
	public static TokenState getTokenState(final String tokenState) {
		final TokenState[] states = TokenState.values();
		TokenState ts = null;
		for (final TokenState state : states) {
			if (state.toString().equals(tokenState)) {
				ts = state;
				break;
			}
		}
		return ts;
	}

	@Override
	public String toString() {
		return this.state;
	}

	public String getState() {
		return state;
	}

	public void setState(final String state) {
		this.state = state;
	}
}
